<html>
  <head>
    <title>React.createRef</title>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/javascript" src="../../js/react.development.js"></script>
    <script type="text/javascript" src="../../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../../js/babel.min.js"></script>
    <script type="text/babel">
      class Demo extends React.Component {
        inputRef1 = React.createRef();
        inputRef2 = React.createRef();

        onClick = () => {
          alert(this.inputRef1.current.value);
        }

        onBlur = () => {
          alert(this.inputRef2.current.value);
        }

        render() {
          return (
            <div>
              <input ref={this.inputRef1} type="text" placeholder="点击按钮显示输入内容" /> &nbsp;
              <button onClick={this.onClick}>点击显示左侧输入内容</button> &nbsp;
              <input ref={this.inputRef2} type="text" onBlur={this.onBlur} placeholder="失去焦点显示输入内容" />
            </div>
          );
        }
      }
      ReactDOM.render(<Demo />, document.getElementById('root'));
    </script>
  </body>
</html>
